package com.benmu.wx.module;

import android.app.Activity;

import com.alibaba.sdk.android.AppLinkService;
import com.alibaba.sdk.android.BaseAlibabaSDK;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXModule;

/**
 * Created by thinkpad on 2018/4/18.
 */

public class TaobaoModule extends WXModule {

    @JSMethod(uiThread = false)
    public void jumpDetail(String id, JSCallback callback) {   // JSCallback 为 WeexSDK 中的 API
        AppLinkService link = BaseAlibabaSDK.getService(AppLinkService.class);
        Activity activity = (Activity) mWXSDKInstance.getContext();
        link.jumpDetail(activity,id);
//        Map<String, String> infos = new HashMap<>();
//        infos.put("board", Build.BOARD);
//        infos.put("brand", Build.BRAND);
//        infos.put("device", Build.DEVICE);
//        infos.put("model", Build.MODEL);
//        callback.invoke(infos);
    }

    @JSMethod(uiThread = false)
    public void jumpURI(String uri, JSCallback callback) {   // JSCallback 为 WeexSDK 中的 API
        AppLinkService link = BaseAlibabaSDK.getService(AppLinkService.class);
        Activity activity = (Activity) mWXSDKInstance.getContext();
        link.jumpTBURI(activity, uri);
    }
}
